index.js ➔ nextTick   C
last analyzed

Complexity

Conditions 9
Paths 6

Size

Total Lines 33
Code Lines 25

Duplication

Lines 1
Ratio 3.03 %

Importance

Changes 0
Metric Value
cc 9
eloc 25
nc 6
nop 4
dl 1
loc 33
rs 6.6666
c 0
b 0
f 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A index.js ➔ ... ➔ afterTick 0 3 1
A index.js ➔ ... ➔ afterTickThree 0 3 1
A index.js ➔ ... ➔ afterTickOne 0 3 1
A index.js ➔ ... ➔ afterTickTwo 0 3 1
1
'use strict';
2
3
if (!process.version ||
4
    process.version.indexOf('v0.') === 0 ||
5
    process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
6
  module.exports = { nextTick: nextTick };
7
} else {
8
  module.exports = process
9
}
10
11 View Code Duplication
function nextTick(fn, arg1, arg2, arg3) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12
  if (typeof fn !== 'function') {
13
    throw new TypeError('"callback" argument must be a function');
14
  }
15
  var len = arguments.length;
16
  var args, i;
17
  switch (len) {
18
  case 0:
19
  case 1:
20
    return process.nextTick(fn);
21
  case 2:
22
    return process.nextTick(function afterTickOne() {
23
      fn.call(null, arg1);
24
    });
25
  case 3:
26
    return process.nextTick(function afterTickTwo() {
27
      fn.call(null, arg1, arg2);
28
    });
29
  case 4:
30
    return process.nextTick(function afterTickThree() {
31
      fn.call(null, arg1, arg2, arg3);
32
    });
33
  default:
34
    args = new Array(len - 1);
35
    i = 0;
36
    while (i < args.length) {
37
      args[i++] = arguments[i];
38
    }
39
    return process.nextTick(function afterTick() {
40
      fn.apply(null, args);
41
    });
42
  }
43
}
44
45